package com.tanhua.server.service;

import com.tanhua.manage.domain.mongo.UserLocation;
import com.tanhua.dubbo.api.UserLocationApi;
import com.tanhua.server.interceptor.UserHolder;
import org.apache.dubbo.config.annotation.Reference;
import org.springframework.stereotype.Service;

import java.util.Map;

@Service
public class LocationService {
    @Reference
    private UserLocationApi userLocationApi;
    /**
     * 上报地理位置
     * @param paramMap
     */
    public void reportLocation(Map<String, Object> paramMap) {
        //纬度
        Double latitude = (Double) paramMap.get("latitude");
        //经度
        Double longitude = (Double) paramMap.get("longitude");
        String address = (String) paramMap.get("addstr");

        //构建用户的位置
        UserLocation userLocation = new UserLocation();
        userLocation.setUserId(UserHolder.getUserId());
        userLocation.setAddress(address);
        //保存
        userLocationApi.save(userLocation,latitude,longitude);
    }
}
